﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/static/include/topLess.jsp"%>
<table>
	<tbody>

		<tr>
			<th><img src="${ctx}/static/images/pages/cen/rig/ico_01.png"
				align="absmiddle">&nbsp;行业选择</th>
		</tr>
		<tr class="tab_grey">
			<td>
				<form name="searchForm" action="" method="post">
					<input type="hidden" id="p" name="p" value="1">
					<span class="tab_text"> 行业名称： </span> <input id="industryName"
						type="text" name="industryName" value="${param['industryName']}"
						size="20" class="tab_textbut" /> <a class="tab_but" href="#"
						onclick="searchForm.action='industrySelect';searchForm.submit();return false;">查询</a> <a
						class="tab_but" href="#" onclick="doneByIds()">保存</a>
				</form> <script>
					$("#industryName").val("${param['industryName']}");
				</script>
			</td>
		</tr>

	</tbody>
</table>



<br />
<c:if test="${empty obj.operationResult}">
	<b>没有符合条件的记录。</b>
</c:if>
<c:if test="${not empty obj.operationResult}">

	<table id="listTable">
		<tbody>
			<tr>
				<th width="5%"><input type="checkbox"
					onclick="selectAll(this.checked);"></th>
				<th>行业名称</th>


			</tr>
			<c:forEach var="oneRow" items="${obj.operationResult}">

				<tr>
					<td><input name="chk" type="checkbox" id="chk"
						value="${oneRow.id}" /></td>
					<td align="left" class="tab_td_rig" name="dustryName">${oneRow.dustryName}</td>
				</tr>
			</c:forEach>
			<tr class="tab_grey">
				<td colspan="7" align="center" valign="middle" class="tab_white">
					<div class="pagination">
						<%@ include file="../../include/listpage2.jsp"%>
					</div>
					<div class="clear"></div>
				</td>
			</tr>

		</tbody>
	</table>
</c:if>
<script>
	function selectAll(checkAllFlag) {
		var checkArray = document.getElementsByName("chk");
		for (var i = 0; i < checkArray.length; i++) {
			checkArray[i].checked = checkAllFlag;
		}
	}

	//查找直属单位
	function chooseIndustry(dustryName) {

		closeWin(dustryName);
	}

	function doneByIds() {

		var str = "";
		var json = "["
		$('input[name="chk"]:checked').each(function() {
			str += $(this).val() + ",";
			
			//取行业名称
			var name = $(this).parent("td").next("td").html();
			
			//拼json串
			json += '{"id":"' + $(this).val() + '","name":"' + name + '"},';
		});

		
		var dot = str.lastIndexOf(",");
		if (dot == -1) {
			layer.alert("请选择行业报表分组！");
			return;
		}
		str = str.substring(0, dot);
		json = json.substring(0, json.lastIndexOf(","));
		json += "]";

		//转型，返回
		var obj = jQuery.parseJSON(json);
		closeWin(obj);

	}
</script>
<%@ include file="/static/include/bottom.jsp"%>
